package lpl.com.xyd.test.manage.domain;

import lombok.Getter;
import lombok.Setter;
import lpl.com.xyd.test.manage.common.domain.Domain;
import lpl.com.xyd.test.manage.common.utils.MD5Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Date;

@Getter
@Setter
public class UserDomain extends Domain {

    private final static Logger LOGGER = LoggerFactory.getLogger(UserDomain.class);

    /** 用户ID */
    private Long id;
    /** 登录名 */
    private String loginName;

    /** 姓名 */
    private String name;

    /** 密码 */
    private String password;

    /** 角色 */
    private String role;

    /** 创建时间 */
    private Date createTime;

    /** 修改时间 */
    private Date updateTime;

    public boolean checkPassWord(String password){
        return this.password.equals(MD5Utils.md5AndBase64Encode(password));
    }

    public void md5AndBase64Encode(){
         this.password = MD5Utils.md5AndBase64Encode(this.password);
    }

    public boolean checkNewPassWord(String password,String confirmPassWord){
        return password.equals(confirmPassWord);
    }

    public void modifyPassWord(String password){
        this.password = MD5Utils.md5AndBase64Encode(password);
    }
}
